package designs.models.observer.more;

import java.util.ArrayList;

public class TravelAgency implements Subject {
	String tourStartTime;
	String tourMess;
	ArrayList<Observer> personList;
	public TravelAgency() {
		personList = new ArrayList<Observer>();
	}
	
	@Override
	public void addObserver(Observer o) {
		if (o == null) {
			return ;
		}

		if (!(personList.contains(o))) {
			personList.add(o);
		}
	}

	@Override
	public void deleteObserver(Observer o) {
		if (personList.contains(o)) {
			personList.remove(o);
		}
	}

	@Override
	public void notifyObservers() {
		for (int i = 0; i < personList.size(); i++) {
			personList.get(i).update(this);
		}

	}
	
	public void giveMess(String time,String mess) {
		tourStartTime = time;
		tourMess = mess;
		notifyObservers();
	}

	public String getTourStartTime() {
		return tourStartTime;
	}

	public String getTourMess() {
		return tourMess;
	}

}
